<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:body>
        <ui:composition template="/resources/template/template.xhtml">
            <ui:define name="content">
                <h:form>
                    <p:panel header="Search Purchase Orders" >
                        <f:facet name="header" >                            
                            <h:outputLabel value="SEARCH RETURN BILL"/>      
                            <h:panelGrid columns="6" >
                                 <p:inputText autocomplete="off" id="txtSearch" value="#{billSearch.txtSearch}"  style="width:500px;">

                                </p:inputText>
                                <p:commandButton ajax="false" value="Search" action="#{billSearch.createReturnSaleBills()}"/>
                                
                                <h:outputLabel value="From Date"/>
                                <p:calendar styleClass="dateTimePicker" id="fromDate" value="#{billSearch.fromDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >                                   

                                </p:calendar>
                                <h:outputLabel value="To Date"/>
                                <p:calendar id="toDate" value="#{billSearch.toDate}" navigator="false" pattern="dd MMMM yyyy hh mm a" >                                  

                                </p:calendar>
                               
                            </h:panelGrid>
                            <p:watermark value="Bill Id ,NetTotal,Paymentscheme,Paymentmethod, Patient Name or Phone Number" for="txtSearch" />
                        </f:facet>


                        <p:dataTable id="tblBills" value="#{billSearch.searchBills}" var="bill" 
                                     paginator="true" rows="20"  lazy="true"
                                     paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"  
                                     rowsPerPageTemplate="5,10,15" >
                          
                            <p:column headerText="Bill No" filterBy="#{bill.deptId}" >                              
                                <h:outputLabel value="#{bill.deptId}" ></h:outputLabel>
                                  
                            </p:column>  
                            <p:column headerText="Date" filterBy="#{bill.createdAt}" >                              
                                    <h:outputLabel value="#{bill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yyyy"/>
                                    </h:outputLabel>                                
                            </p:column>
                            <p:column headerText="Time" filterBy="#{bill.createdAt}">                              
                                    <h:outputLabel value="#{bill.createdAt}" >
                                        <f:convertDateTime pattern="hh:mm a"/>
                                    </h:outputLabel>                                   
                            </p:column>                           
                            <p:column headerText="Billed By" filterBy="#{bill.creater.webUserPerson.name}" >                             
                                    <h:outputLabel value="#{bill.creater.webUserPerson.name}" ></h:outputLabel>                                  
                            </p:column>     
                            <p:column>
                                <p:commandButton ajax="false" disabled="#{bill.referenceBill ne null or bill.cancelled}" value="Cancel Return Item Bill" action="pharmacy_reprint_bill_return_pre">
                                     <f:setPropertyActionListener value="#{bill}" target="#{pharmacyBillSearch.bill}"/>
                                </p:commandButton>                                
                            </p:column>
                            <p:column headerText="Cash Refunded Date" filterBy="#{bill.referenceBill.createdAt}" >
                                
                                    <h:outputLabel value="#{bill.referenceBill.createdAt}" >
                                        <f:convertDateTime pattern="dd MM yyyy"/>
                                    </h:outputLabel>
                                   
                            </p:column>
                            <p:column headerText="Cash Refund By" filterBy="#{bill.referenceBill.creater.webUserPerson.name}">
                                
                                    <h:outputLabel value="#{bill.referenceBill.creater.webUserPerson.name}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                 
                            </p:column>
                            <p:column headerText="Net Value" filterBy="#{bill.referenceBill.netTotal}">
                          
                                    <h:outputLabel value="#{bill.referenceBill.netTotal}" >
                                        <f:convertNumber pattern="#,##0.00"/>
                                    </h:outputLabel>
                                  
                            </p:column>
                            <p:column>
                                <p:commandButton ajax="false" rendered="#{bill.referenceBill ne null}" value="Cancel Refund Cash Bill" action="pharmacy_reprint_bill_return_cash">
                                     <f:setPropertyActionListener value="#{bill.referenceBill}" target="#{pharmacyBillSearch.bill}"/>
                                </p:commandButton>     
                            </p:column>

                        </p:dataTable>


                    </p:panel>

                </h:form>
            </ui:define>


        </ui:composition>

    </h:body>
</html>
